import { ConfigEnv, defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';

export default defineConfig((mode: ConfigEnv) => {
  const env = loadEnv(mode.mode, process.cwd());
  return {
    plugins: [vue(),
      Components({
        resolvers: [VantResolver()],
      }),
    ],
    //配置src的路径别名 @ 
    resolve:{
     alias:{
       "@":path.resolve(__dirname,'src')
     },
    //  extensions: [".ts", ".js", ".jsx", ".tsx"], // 导入时想要省略的扩展名列表。
   },
   server: {
       proxy: {
         // 选项写法
         "/api": {
           target: "http://gmall-h5-api.atguigu.cn",
           changeOrigin: true, //重写api的  看路径有没有
          //  rewrite: (path) => path.replace(/^\/app-dev/, ""),
         },
         "/app-dev": {
          target: "https://m.you.163.com",
          changeOrigin: true, //重写api的  看路径有没有
          rewrite: (path) => path.replace(/^\/app-dev/, ""),
        },
       },
     },
  };
});

